//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_FILE_SYSTEM_H
#define _UX_FILE_SYSTEM_H

#include "../Core/CCore.h"
#include "IFile.h"
#include "CFileBuf.h"
#include "IVirtualFileSys.h"

namespace Engine
{
namespace CoreSystems
{


	//
	// File System
	//

	class _EXPORT_ CFileSystem : public CEngBaseObject
	{
		friend class Engine::CoreSystems::CCore;

	private:
		array< IVirtualFileSys *>	_aFileSystems;

	protected:
		CFileSystem();
		~CFileSystem();

		bool	Init();

		// CEngBaseObject //
		virtual void Release();

	public:
		bool GetVirtualFileSystem(e_file::type eType, IVirtualFileSys *&pVFS);
		bool RegisterFileSystem(IVirtualFileSys *pVFS);
		bool UnregisterFileSystem(IVirtualFileSys *pVFS);
		bool UnregisterFileSystem(e_file::type eType);

		bool OpenFile(const char *pFileName, IFilePtr &pFile, e_file_open_flags::type eFlags);
		bool OpenCryptFile(const char *pFileName, const char *pPassword, IFilePtr &pFile, e_file_open_flags::type eFlags);
		bool OpenFileBuf(const char *pFileName, IFilePtr &pFile);
		bool CreateFileBuf(IFilePtr &pFile);
		bool OpenResource(const TLibrary &sLib, uint uID, IFilePtr &pFile);

		bool SetCurDirectory(const char *pDirectory) const;
		bool GetCurDirectory(string &sDirectory) const;

		bool GetAllFilesInPath(const char *pPath, string_array_t &aFileNames) const;
		bool GetAllDirsInPath(const char *pPath, string_array_t &aDirectories) const;
		
		bool FileExist(const char *pFileName) const;
		bool FileExistEx(const char *pFileName) const;
		bool DirectoryExist(const char *pDirName) const;
		bool NewDirectory(const char *pDirName) const;
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// _UX_FILE_SYSTEM_H